package org.mindrive.system;

import javax.servlet.MultipartConfigElement;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.util.unit.DataSize;

@Slf4j
@SpringBootApplication
@EnableScheduling //开启定时任务
@MapperScan(value = { "org.mindrive.system.dao.mapper" })
public class PlatformApplication extends SpringBootServletInitializer {


	public static void main(String[] args) {
		SpringApplication.run(PlatformApplication.class, args);
	}

	//重写configure方法
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		return builder.sources(PlatformApplication.class);
	}

	@Bean
	public MultipartConfigElement multipartConfigElement() {
		MultipartConfigFactory factory = new MultipartConfigFactory();
		// 单个文件最大
		factory.setMaxFileSize(DataSize.ofGigabytes(6)); // KB,MB
		// 设置总上传数据总大小
		factory.setMaxRequestSize(DataSize.ofGigabytes(6));
		return factory.createMultipartConfig();

	}
}